﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace 人事工资管理系统
{
    public partial class frmUserPrize : Form
    {
        public frmUserPrize()
        {
            InitializeComponent();
        }
        PMSClass.DBOperate operate = new PMSClass.DBOperate();
        private void frmUserPrize_Load(object sender, EventArgs e)
        {
            string getJFstr = "select UserID as '员工编号',UserName as '员工姓名',UserDep as '所属部门',UserJF as '奖/惩',UserJFcontent as '奖罚内容',UserJLMoney as '奖励金额',UserFKMoney as '罚款金额',UserJFDate as '奖罚日期',UserCXDate as '撤销日期' from tb_prize";
            operate.BindDataGridView(dataGridView1, getJFstr);
        }

      

        private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            string id = dataGridView1.SelectedCells[0].Value.ToString();
            string name = dataGridView1.SelectedCells[1].Value.ToString();
            frmChangePrize prize=new frmChangePrize();
            //prize.Uid = id;
            //prize.Uname = name;
            prize.ShowDialog();

        }

     

        private void toolStripLabel1_Click(object sender, EventArgs e)
        {
            frmJFmanage employee = new frmJFmanage();
            employee.ShowDialog();
        }

        private void toolStripLabel2_Click(object sender, EventArgs e)
        {
            frmChangePrize prize = new frmChangePrize();
            prize.ShowDialog();
        }

        private void toolStripLabel3_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedCells.Count == 0)
            {
                MessageBox.Show("请选择要删除的信息", "警告", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            else
            {
                string id = dataGridView1.SelectedCells[0].Value.ToString();
                string sql = "delete from tb_prize where UserID='" + id + "'";
                operate.OperateData(sql);
                MessageBox.Show("删除成功", "警告", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }

        private void toolStripLabel5_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void toolStripTextBox2_TextChanged(object sender, EventArgs e)
        {
            string str =
"select UserID as '员工编号',UserName as '员工姓名',UserDep as '所属部门',UserJF as '奖/惩',UserJFcontent as '奖罚内容',UserJLMoney as '奖励金额',UserFKMoney as '罚款金额',UserJFDate as '奖罚日期',UserCXDate as '撤销日期' from tb_prize where UserName like '%" + toolStripTextBox2.Text.Trim() + "%'";
            operate.BindDataGridView(dataGridView1, str);
            dataGridView1.Columns[0].Width = 40;
            dataGridView1.Columns[1].Width = 80;
        }
    }
}
